from ultralytics import YOLO
# 加载模型
model = YOLO("runs/detect/train8/weights/last.pt")  # 推荐加载预训练权重
if __name__ == '__main__':
    # 训练配置
    results = model.train(
        data="ultralytics/cfg/datasets/helmet.yaml",
        cfg="ultralytics/cfg/datasets/helmet20250716-1.yaml",  # 训练超参数配置
        epochs=200,
        resume=True,  # 关键参数
        batch=16,
        imgsz=736,
        device=0,
        project="runs/detect",
        workers=0  # 关键！Windows下禁用多进程数据加载
    )

# yolo task=detect mode=train model=weights/yolov8n.pt data=ultralytics/cfg/datasets/CCPD-test.yaml batch=16 epochs=50 imgsz=416 workers=1 device=0 project=runs/detect